package com.gxp.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gxp.mapper.SiteSettingMapper;
import com.gxp.pojo.SiteSetting;
import com.gxp.service.SiteSettingService;

@Service
@Transactional
public class SiteSettingServiceImpl implements SiteSettingService {

	@Autowired
	private SiteSettingMapper siteMapper;
	@Override
	public Map<String, String> getSiteSetting() {
		List<SiteSetting> settingList = siteMapper.getAllSettings();
		Map<String, String> resultMap = new HashMap<String, String>();
		for (SiteSetting setting : settingList) {
			resultMap.put(setting.getKey(), setting.getContent());
		}
		return resultMap;
	}
	@Override
	public void updateSiteSetting(SiteSetting setting) {
		siteMapper.updateSiteSetting(setting);
	}

	@Override
	public String getSiteSettingByKey(String settingKey) {
		return siteMapper.getSettingByKey(settingKey);
	}

}
